from selenium import  webdriver
from selenium.webdriver.common.by import By
from time import sleep

op = webdriver.ChromeOptions()
op.add_experimental_option("excludeSwitches", ["enable-automation"])
op.add_experimental_option("useAutomationExtension", False)
driver = webdriver.Chrome(options = op)

driver.get('http://news.baidu.com/')
biaoti = driver.find_element(By.CSS_SELECTOR,"#pane-news > div > ul > li.hdline1 > strong > a:nth-child(1) > b")
content = biaoti.text
biaoti.click()
sleep(2)
all_handles = driver.window_handles
driver.switch_to.window(all_handles[1])
title = driver.title
assert content in driver.title
driver.close()
driver.switch_to.window(all_handles[0])

test = driver.find_element(By.CSS_SELECTOR,"#ww")
test.send_keys("中国文化")
driver.find_element(By.CSS_SELECTOR,"#s_btn_wr").click()
assert "中国文化" in driver.title


driver.quit()
